package com.yc.damai.dao;

import java.util.List;
import java.util.Map;

import com.yc.damai.bean.Orderitem;
import com.yc.damai.bean.User;
import com.yc.damai.util.DBHelper;

public class OlistDao {

	//根据登录的用户uid查询订单编号    List<>
	public static  List<Map<String, Object>> OrderById(int uid){
		String sql ="select b.oid,b.total,b.state from"
				+ " orders b join user a  on a.uid = b.uid"
				+ " where a.uid = ? order by oid";
		return DBHelper.query(sql, uid);
	}
	
	//根据uid查询订单详情
	public static  List<Map<String, Object>> OrderByUid(int uid){
		String sql ="select o.oid,p.image,p.pname,"
				+ "p.shop_price,o.count,p.shop_price*o.count  "
				+ "from product p inner join orderitem o "
				+ "on p.pid = o.pid inner join orders b on b.oid=o.oid"
				+ " where b.uid=?";
		return DBHelper.query(sql, uid);
	}
}
